
clear; clc;
path = pwd;
addpath(genpath(path));
addpath(fullfile(pwd, '..', 'lib'));
 dataName = { 'bbcnewssport_737n_1000d_5c_uni_12k','RELATHE_1427n_4322d_2c_tfidf_uni_12k',...
    'warpPIE10P_210n_2420d_10c_12k','COIL20_1440n_1024d_20c_uni_12k',...
    'UMIST_575n_644d_20c_12k','BASEHOCK_1993n_4862d_2c_tfidf_uni_12k',...
     'leukemia_72n_7070d_2c_12k','ALLAML_72n_7129d_2c_12k',...   
};
      
   indicator={'acc_rmkkm_res','nmi_rmkkm_res','purity_rmkkm_res'}   
for i1 =2:length(dataName)
    load(fullfile(pwd, '..', 'data', dataName{i1}));
    nRepeat = 1;
     load(fullfile(pwd, '..', 'rmkkm_res.mat'));
    for ind=1:3
    s=eval([indicator{ind}]);
    gammas = s(i1);
    Ks2 = zeros(size(Ks));
    for i2 = 1:size(Ks,3)
        Ktmp = knorm(Ks(:,:,i2));
        if max(Ktmp(:)) > 1
            Ktmp = Ktmp  / max(Ktmp(:));
        end
        Ks2(:,:,i2) = Ktmp;
    end
 
    [res_rmkkm, timeElapsed1, best_rmkkm,biaozhuncha,fangcha] = RMKKM_single_dataset(Ks2, Y, gammas, nRepeat);
     res_rmkkm=res_rmkkm(:,ind);
    biaozhuncha=biaozhuncha(:,ind);
    fangcha=fangcha(:,ind);
    best_rmkkm=best_rmkkm(:,ind);
    save([dataName{i1},'_', indicator{ind},'_.mat'],  'res_rmkkm', 'best_rmkkm');
    save(['..\','metricresult\',dataName{i1},'_', indicator{ind},'_.mat'],  'res_rmkkm', 'best_rmkkm');
    end
end
